
APP_NAME := $(shell test -f go.mod && grep '^module ' go.mod | head -1 | awk '{print $$2}' | xargs basename || basename $(PWD))

.PHONY: all linux-amd64 linux-arm64 darwin-amd64 darwin-arm64 windows-amd64 local clean

all: linux-amd64

linux-amd64:
	GOOS=linux GOARCH=amd64 go build -o $(APP_NAME)-linux-amd64

linux-arm64:
	GOOS=linux GOARCH=arm64 go build -o $(APP_NAME)-linux-arm64

darwin-amd64:
	GOOS=darwin GOARCH=amd64 go build -o $(APP_NAME)-darwin-amd64

darwin-arm64:
	GOOS=darwin GOARCH=arm64 go build -o $(APP_NAME)-darwin-arm64

windows-amd64:
	GOOS=windows GOARCH=amd64 go build -o $(APP_NAME)-windows-amd64.exe

local:
	go build -o $(APP_NAME)

clean:
	rm -f $(APP_NAME)*
